home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine CD 1995
/
Archive Magazine CD 1995.iso
/
text
/
hints
/
volume_05
/
issue_11
< prev
next >
Wrap
Text File
|
1995-02-16
|
24KB
|
636 lines
Hints and Tips
5.11
• A5000 hard disc replacement − One drawback with the A5000 is that the
40M hard disc quickly fills up. Being in this position, I decided to
replace mine with a larger one.
5.11
Researching prices, I found that IDE drives bought direct from suppliers
advertising in magazines such as Personal Computer World are much
cheaper than the same drives advertised in the specialist Acorn
magazines. Would any IDE drive work? A friend told me that Seagate IDE
drives did not work correctly on A5000s but Connor (as already fitted to
my A5000) and Maxtor (as fitted to another A5000 I know of) should be
OK, as well as Quantum. Another friend recently bought and fitted an NEC
drive to his A5000.
5.11
I bought a 120M cached Quantum drive (the GM120AT). The drive, from SMC
who advertise in PCW, arrived the day after I ordered it.
5.11
The fitting was extremely simple. After a backup and power off I removed
the cables, undid the four screws under the old drive (it is necessary
to remove all the drive cables and lift out the metal bracket to which
the drives are fastened) to release it and slotted in the new one − no
problems! The drive was already low-level formatted and, although the
hard disc formatter supplied with RISC-OS 3 didn’t recognise the disc
shape, I just selected ‘Initialise’ and that was it. The drive worked a
few seconds after switching on.
5.11
In use, the drive feels very fast. I have measured a data transfer rate
of 1060k/sec, compared to 800k/sec for the original drive and an average
access time of 7ms(!) as compared to 18ms.
5.11
Similar drives advertised specifically for the A5000 in the Acorn press
are £50£100 more. Some of these include splitter cables, allowing the
old drive to remain (there are already mounting holes for a second drive
on the A5000, drilled in the case below the floppy disc drive). I intend
to make my own in the next few days − it will cost about £10.
5.11
So I would recommend anyone wishing to upgrade their A5000’s internal
disc drive to do it themselves. Just obey the following rules:
5.11
− Shop around for the best deal in the general computer and PC press.
5.11
− Buy a low profile 3½“ AT IDE drive made by Quantum, Conner, Maxtor or
NEC.
5.11
− Make a backup of your old hard disc before commencing the changeover.
5.11
− Use the RISC-OS 3 hard disc formatter to initialise the new disc, no
need to format.
5.11
− If you want to use both drives, Maplin Electronics sell everything
you need to make the splitter cables.
5.11
Perhaps a list of known A5000-friendly IDE drives could be compiled?
Seán Kelly, Leighton Buzzard
5.11
• Acorn SCSI card − If you buy the CDFS/FSCSI upgrade for the Acorn SCSI
card, there is a link change to be made on the AKA31 version of the card
but if you have one of the older AKA30 cards, it is slightly more
complicated.
5.11
The upgrade consists of putting a 27512 EPROM in place of the existing
27256 EPROM. To enable the extra address lines, hardware modifications
are needed. Links 1, 3, 4 and 5 remain unchanged but link LK2 was open
and has to be closed and link LK12 was closed and has to be opened. On
the AKA31 boards, these changes can be made by moving a link but on the
AKA31, this will involve cutting a track on LK12 and soldering a link on
LK2. This should not be attempted unless you are competent to make such
a modification and it will, in any case, invalidate the warranty on the
board. Acorn dealers should do the modification for you although there
may be a charge unless you buy the upgrade from them. Tudor Jones,
Barnet.
5.11
• Automatic kerning and RISC-OS 3 − The font manager has this facility.
Currently it is only available with the standard ROM fonts (Trinity,
etc.). Presumably, EFF will update their fonts to include kerning pairs.
To use auto-kerning, simply set bit 9 of R2 in all calls to SYS
“Font_Paint”.
5.11
10 REM >KernDemo
5.11
20 REM Example of automatic kerning
5.11
30 REM For RISC-OS 3 ROM fonts only
5.11
40 MODE 15:OFF
5.11
50 SYS “ColourTrans_SetFontColours”,0,0,
5.11
&F0F00000,14
5.11
60 SYS “Font_FindFont”,,“Trinity. Medium”,50*16,50*16 TO hdl%
5.11
70 SYS “Font_SetFont”,hdl%
5.11
80 REM Kerning off first
5.11
90 SYS “Font_Paint”,,“WAWA no
5.11
kerning here!“,%0000010000,10,500
5.11
100 REM Kerning on now
5.11
110 REM Set bit 9 in R2
5.11
120 SYS “Font_Paint”,,“WAWA this is kerned.”,%1000010000,10,300
5.11
130 SYS“Font_LoseFont”,hdl%
5.11
The ease with which this can be done leads me to wonder why CC haven’t
provided it as an option in Impression.
5.11
To rotate fonts, set bit seven of R2 in “Font_ Paint” and pass the (draw
style) transformation matrix in R7. Note that old style calls to
“Font_StringWidth”, etc don’t take account of kerning or transformation.
A new SWI “Font_ ScanString” is used to do this. Rob Davison, New
Zealand
5.11
• Basic 1.05 Bug − A really annoying bug exists in all versions of Basic
except the floating point version supplied on the RISC-OS 3 application
discs.
5.11
Consider the following two statements (type them in if you feel like
it.)
5.11
a=210
5.11
b=2.10*100
5.11
These two variables should hold the same value. They seem to be the
same, as you can check with:
5.11
PRINT a,b
5.11
IF a=b PRINT “SAME”
5.11
etc.
5.11
If you have RISC-OS 2 then both the above checks will say that they are
the same. RISC-OS 3 Basic 1.05 will not print ‘SAME’ in the second test.
The reason for this can be revealed by trying the following:
5.11
PRINT INT(a),INT(b)
5.11
PRINT STR$(a),STR$(b)
5.11
These problems seem to occur because of the limited accuracy of floating
point numbers in Basic. My program stored times at centisecond resolu
tion internally and I wanted to scale these times to seconds for the
user. I did a usertime=centitime/100 but ran into problems when I tried
converting the usertime variable back into a string with STR$(usertime)
5.11
My solution (and I’m not saying it’s a good one) is as follows:
5.11
A short ARM code routine intercepts the WRCHV vector and stores
characters printed in a buffer. The routine is linked in just before a
PRINT realvar statement and killed off just afterwards. You can then
extract the string from the buffer via normal means. An example program
follows:
5.11
10 REM >string
5.11
20 REM provides a STR$( function
5.11
25 REM that avoids some floating
5.11
30 REM point problems in Basic
5.11
40 REM By Rob Davison, May 1992
5.11
50 REM Public Domain
5.11
60 REM
5.11
70 PROCassy
5.11
80 PRINT “First the old way -”
5.11
90 PRINT STR$(2.10*100)
5.11
100 PRINT “Should be ”;FNstr(2.10 *100)
5.11
110 PRINT’“Another example”
5.11
120 PRINT STR$(0.6)
5.11
130 PRINT “Should be ”;FNstr(0.6)
5.11
140 PRINT’“Bye now.”
5.11
150 END
5.11
160 DEFPROCassy
5.11
170 DIM code% &100
5.11
180 REM ’possy’ is a buffer. Can be scratch space but MUST
5.11
be big enough.
5.11
190 DIM possy &100
5.11
200 FOR opt=0 TO 2 STEP2
5.11
210 P%=code%
5.11
220 [OPT opt
5.11
230 .intercept
5.11
240 STMFD R13!,{r0-r3 }
5.11
250 LDR R1,posaddr
5.11
260 STRB R0,[R1]
5.11
270 ADD R1,R1,#1
5.11
280 STR R1,posaddr
5.11
290 LDMFD R13!,{r0-r3 ,PC}
5.11
300 .posaddr EQUD possy
5.11
310 ]
5.11
320 NEXT
5.11
330 ENDPROC
5.11
340 REM this is the string function
5.11
350 DEFFNstr(number)
5.11
360 LOCAL ERROR
5.11
370 ON ERROR LOCAL SYS “XOS_Release” ,3,intercept,0:REPORT:PRINT ERL:END
5.11
380 !posaddr=possy:REM reset pointer to start of buffer
5.11
390 SYS “XOS_Claim”,3,intercept,0 :REM claim the vector
5.11
400 PRINT number
5.11
410 SYS “XOS_Release”,3,intercept,0 :REM and release it immediately
5.11
420 REM Extract the string and get rid of leading/trailing rubbish
5.11
430 str$=$possy:WHILE LEFT$(str$,1)= CHR$32:str$=RIGHT$(str$,
5.11
LEN(str$)-1):ENDWHILE
5.11
440 WHILE ASC(RIGHT$(str$,1))<32: str$=LEFT$(str$,LEN(str$)-1)
5.11
:ENDWHILE
5.11
450 =str$
5.11
Rob Davison, New Zealand
5.11
• Basic V rounding errors − Last month, (Archive 5.10 p19) Mr E. Hollox
asked for help with the STR$ rounding. I hope that the following will
help solve his problem. No actual specifics were given on his problem,
so I’ve assumed that he’s working with monetary units (i.e. two decimal
places). This may not be correct in this instance, but will probably be
relevant to a large number of users and should provide Mr Hollox with a
starting point for the solution he wants.
5.11
In simple terms, the solution is to avoid decimals; to work only with
integer variables. At first glance this may sound like an odd solution
when a number of decimal places are required, but it’s not as strange as
you may think.
5.11
Firstly, the use of integer variables does not restrict you to the use
of integer numbers − not when you are making use of STR$, anyway.
5.11
Secondly, integers make for faster programs, as I’m sure everyone
realises (unless they program an Atari ST in GFA or Atari Basic!)
5.11
Thirdly, and more importantly, integers are far more accurate than real
numbers due to the way in which they are stored. The method of storage
does have a negative effect, however, in that your range of numbers is
restricted − though the range available should be enough for most
people’s needs. Page 21 of the Archimedes’ BBC Basic Guide details this.
Remember that the more decimal places you require, the lower the range
becomes.
5.11
So, onto the solution to the problem...
5.11
Your ‘real’ number must be stored as an integer 100 (for 2 dp users)
times as big. Whenever any output is required, a routine must be used to
convert it to a string and insert a decimal point at the correct place.
For inputting, the reverse is required; the decimal point must be
removed.
5.11
The function FN_Int_To_Str carries out the decimalisation of your
integer number:
5.11
DEF FN_Int_To_Str(Int%)
5.11
LOCAL Real$
5.11
Int%=ABS(Int%)
5.11
IF Int%<10 THEN Real$=
5.11
“ 00”+STR$(Int%)
5.11
IF Int%>=10 AND Int%<100 THEN Real$=“ 0”+STR$(Int%)
5.11
IF Int%>=100 THEN Real$=RIGHT$
5.11
(“ ”+STR$(Int%),9)
5.11
Real$=LEFT$(Real$,7)+“.”+
5.11
RIGHT$(Real$,2)
5.11
=Real$
5.11
You must call the function with string$=FN_Int_ To_Str(number%) where
string$ is your variable to hold the decimalised string and number% is
your variable holding the stored number. The routine returns the number
as a string with two decimal places, and right justified (in a ten
character field).
5.11
The minus symbol ruins the simplicity of the routine, so an absolute
value is taken of the number. Minus numbers aren’t difficult to cope
with but, as they weren’t part of the problem....
5.11
The function works by converting the integer number to a string and then
adding spaces to the left in order to right align it. This is done by
the three IF statements and, possibly, is the more complex part of the
routine.
5.11
In the first case, the number is lower than ten (i.e. 0 to 9) so the
final figure will be of the form “ 0.0x” − hence six spaces and two
zeros are added.
5.11
In the second case, the number is in the range 10 to 99, so the figure
will be “ 0.xx” − six spaces and one zero are added.
5.11
In the third case, the number is over 100 (over 1.00). In this case,
rather than add the correct number of spaces for its size (6 for 100 to
999, 5 for 1000 to 9999, etc.) we add the maximum required and truncate
the resulting string to its rightmost nine characters.
5.11
The result, in all three cases, is a right aligned integer number in a
nine character string.
5.11
Then we have the easy bit. The first seven characters of the string are
taken, a decimal point added, then the last two digits − problem solved.
5.11
The reverse function is even simpler:
5.11
DEF FN_Str_To_Int(Real$)
5.11
LOCAL Int%
5.11
Real$=FN_FormatNumber(Real$)
5.11
Int%=VAL(LEFT$(Real$,7))*100+
5.11
VAL(RIGHT$(Real$,2))
5.11
=Int%
5.11
This function is called with number%=FN_Str_ To_Int(string$) where
string$ is your variable containing the string and number% is the
variable that will contain the integer number.
5.11
The first thing the function does is to pass the string to another
function in order to ensure it is of the correct format before convert
ing it to a number. This is dealt with below.
5.11
The function then calculates the integer part of the number (positions 1
to 7 within the string), multiplies this by 100, and adds the fractional
part of the number (positions 9 to 10 − after the decimal point.) The
result, an integer number 100 times the real number, is returned to the
calling routine.
5.11
I could have simply used Int%=VAL(Real$)*100, making the routine much
simpler. Then the inaccuracy of real numbers is risked once more. In
between Real$ and Int%, the number is stored as real until it is
multiplied by 100 and put in the integer variable. The method I’ve used
circumvents this risk, but introduces another factor. The format of the
number within the string must be correct. For the above conversion to
work, this must be a two decimal place number, with the decimal point as
the eighth character of the string. This is where the third formula
comes in:-
5.11
DEF FN_FormatNumber(Number$)
5.11
LOCAL Length%,Point%
5.11
Length%=LEN(Number$)
5.11
Point%=INSTR(Number$,“.”)
5.11
IF (Point%=Length%-1) AND
5.11
(Point%>0) THEN Number$=Number$+“0”
5.11
IF (Point%=Length%) AND (Point%>0) THEN Number$=Number$+“00”
5.11
IF Length%=0 THEN Number$=“0”
5.11
IF Point%=0 THEN Number$=Number$+ “.00”
5.11
IF Point%=1 THEN Number$=“0”+ Number$
5.11
Number$=RIGHT$(“ ”+Number$ ,10)
5.11
=Number$
5.11
This routine looks far more complicated than it actually is. The second
routine, above, passes its Real$ to this function which formats it to
two decimal places and ensures that the final string is 10 characters
long.
5.11
In this sense, it is a routine that can be used independently of the
other two; by calling it with New$=FN_FormatNumber(Old$) where Old$ is
the unformatted number and New$ is the result.
5.11
It works by determining first the length of the string, then the
position of the decimal point within the string. With a two decimal
place number, the position of the point would be 2 less than the length
of the string.
5.11
The first IF statement adds a single zero if the position of the point
is 1 less than the string’s length but only if the decimal point’s
position is larger than zero − in which case the number is an integer
and would have been accidentally multiplied by ten.
5.11
The second IF adds a double zero if the point is at the end of the
string. This is not done if the position of the point is zero, in which
case the string is null and represents nothing.
5.11
The third makes the string equal to “0” if it is found to be null.
5.11
The fourth adds “.00” to the end of the string if there is no decimal
point − i.e. if the number is an integer.
5.11
The combination of the third and fourth IF’s result in the null string
(“”) becoming “0.00”
5.11
The fifth IF adds a zero to the string if the decimal point is at the
very beginning − if the number is lower than one and is lacking the
leading zero.
5.11
Finally, before returning the result, a number of spaces are added to
the left of the number which is then truncated to the rightmost ten
characters. Hey presto, a nicely formatted number.
5.11
The three routines are on the enclosed disk, in the form of a procedure
library − details of how to use such are on page 92 of the BBC Basic
Guide.
5.11
Though the routines, as given, are for numbers with two decimal places −
and with a field width of ten − it shouldn’t be too difficult to alter
them for other requirements. Unfortunately, the higher the number of
decimal places, the more (and more complicated) IF’s are required. It
shouldn’t be too difficult to write routines that accept the number for
conversion, together with the number of decimal places and the field
width but, as I said before, this was just intended to provide Mr Hollox
with a starting point for his solution. Vince Hudd, Soft Rock Software.
5.11
• Bible Master with RISC-OS 3 − Having found a list of verses or cross
references, it is possible to import the text into an Archimedes word
processing (or DTP) package.
5.11
(i) Load the PC text into !Edit and then
5.11
(ii) Use the wildcard search and replace option searching for %[ $x76-
xFF] (note that the square brackets start with a space) and replacing
with a space.
5.11
This will remove all the screen control characters and multiple spaces.
The resulting text can then be saved and/or loaded into most word
processors. S Wright, Basingstoke
5.11
• Deskjet 500C and RISC-OS 3 − Recent contributors on the subject of the
HP Deskjet 500C have tended to concentrate on the best type of paper to
use. I will not attempt to further that debate, but rather recount my
efforts to produce envelopes to match the quality of their contents.
This turned out to be less straightforward than I had expected but I
eventually succeeded. Most of my printing is from Impression Junior, so
the following will apply to Impression II users and, although I am using
an A5000, the RISC-OS 2 drivers are not crucially different.
5.11
Using the Alter Pages sub-menu in Junior, create a custom page the same
size as the envelope. A standard A4 envelope seems to be 218mm by 110mm.
Create a suitable frame for the name and address and save the file as
‘envelope’. Load the !Printers application and create a custom page of
the same size, also called ‘envelope’. I have used margins of 10mm all
round which show up unambiguously in the Junior window. Click on <Save
Settings> in the page set-up menu and <Save Choices> from the main menu.
Go to the ‘configure’ option from the printer control menu, select the
new ‘envelope’ option and click on OK. The printer margins will now be
visible in the Junior window. Insert an envelope face down in the out-
tray of the printer, sliding it into the guide slots provided and
keeping the right hand edge against the edge of the tray. At this point,
the HP manual is misleading. Do NOT press the envelope button on the
printer. Simply press <Print> on the computer and then <Return>. The
envelope will now be properly printed. If the envelope button on the
printer has been pressed, the envelope will be passed disdainfully
through the printer and the address will appear on the next sheet of
paper from the in-tray.
5.11
In the prison where I work, I have recently been involved in running an
Anger Control Programme which required a couple of dozen overhead
projector transparencies. These can be produced to a high standard on
the 500C and, of course, in full colour. The transparencies used must be
designed for use with inkjet printers since they require a special
material to absorb the ink. There is, however, one major problem − the
appropriate material is rather expensive. Hewlett Packard’s own
transparencies cost about £75 inc. VAT for a box of 100. For me, this is
too many and far too much money. Eventually, I found that NOBO produce a
box of 50 for a slightly lower price per transparency and these should
be available from a good office supplies firm. The inadequate black
produced by the colour cartridge on the 500C is particularly noticeable
on an OHP and I found that a more satisfactory result could be obtained
by printing each transparency twice; once for black and once for the
coloured areas. Registration seems not to be a problem for the bold text
and graphics which are the norm for this kind of presentation. This
technique also saved an awful lot of expensive, coloured ink.
5.11
Incidentally, the UNDO facility on RISC-OS3 !Draw(or in !DrawPlus) was a
considerable help in creating the colour ‘separations’ for this process.
I could delete either the black or the coloured areas of the image
before printing and restore them by pressing <F8>. A Trout, Lancs.
5.11
• Deskjet 500 DIP switches − For those just buying Deskjet 500 printers,
it may be worth knowing that the default setting of the DIP switches is
not too helpful. Try the following settings instead...
5.11
Bank A Bank B
5.11
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7
5.11
¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯
5.11
This seems to work OK − it sets things like skip-over-perforation OFF
and A4 paper instead of some US size. Steve Hutchinson, Gloucester.
5.11
• Dragging solid sprites − RISC-OS 3 has, built in, the ability to solid
drag sprites from save dialog boxes. The solid drag option is stored in
CMOS in a ‘hidden’ location on bit 1 of byte 28. The following commands
will set bit 1 without disturbing anything else in this byte.
5.11
*Basic
5.11
SYS “OS_Byte”,161,28 TO ,,v%
5.11
v%=v% OR %10
5.11
SYS “OS_Byte”,162,28,v%
5.11
Now try saving a file from Draw/Edit/Paint, etc.
5.11
(Comparing the A5000 to an A440/1+30Mhz ARM3, the 440 runs at about the
same speed as the A5000 in mode 12, but at about 1/3 of the speed in
mode 28.) Rob Davison, New Zealand
5.11
• Personalised application templates − Many users may not have realised
that it is often possible to alter the windows and templates used by an
application. Most programmers use the FormEd application or one of its
derivatives to create a Template file which contains the window
definitions used by the program and this can often be seen in the
application directory normally called, not surprisingly, Templates.
5.11
If you have a copy of FormEd, which is supplied with all Acorn’s
compilers but is also available from most PD libraries (Shareware Disc
20, Ed), you can load these templates and alter them to suit your own
ideas and preferences. What you must not do is change the number of any
of the icons or the program won’t behave properly. You must also be
careful if you create any extra icons that they don’t overlay any
existing button icons since the Wimp doesn’t report clicks on icons
which are hidden behind others with a higher number.
5.11
As an illustration, I have included a set of modified windows for Edit.
Since some of these now use sprites there is also a sprite file and you
must insert a line to load these in the !Run file or the windows will
look rather bare. For simplicity, I have included a !Run file with the
extra line in it.
5.11
Rename your existing !Run and Templates files something else (in case
you don’t like mine) and copy the files !Run, Templates and sprites2
into the !Edit application directory. Now when you run Edit the new
windows will be used.
5.11
Note that the main text window is also changed. When Edit opens a new
file the main text window opens in whatever form the template was
created. Just load the Templates file into FormEd and drag the text
window around the screen and resize it until you are satisfied. Then
save the templates. Next time you open an Edit window, that is the size
and position it will assume.
5.11
I don’t claim that these examples are particularly brilliant but they
are certainly an improvement on the original and will help to show how
you can customise standard programs. David Holden, Sydenham.
5.11
• Pinboard problems − Several people (well, at least two anyway!) appear
to have had problems with Pinboard running under RISC-OS 3. It would
seem that the Pinboard module is automatically UNPLUGged following an
exit from the desktop. One solution involves using an alias to re-
initialise the Pinboard. If you have a desktop !Boot file then, before
the Pinboard command (if there is one), insert something like the
following:
5.11
Set Alias$NewDesktop %RMreinit Pinboard |m %Desktop |m
5.11
Obviously, in place of NewDesktop you can use any name that you like
(note that abbreviations still work so, in this case, you could use New.
to carry this out.) If you wish to re-run the !Boot file on exiting
from command line mode, add -F !Boot after the %Desktop command. If you
do not have a desktop !Boot file, use the Desktop Boot function from the
Acorn menu on the iconbar.
5.11
From now on, to get back from the command line (after using the Exit
option), type New. (or your appropriate alias) rather than Desktop.
5.11
Simon Moy, Norwich Computer Services.
5.11
• Truncated filenames and RISC-OS 3 − It took me a long time to discover
that you type *Configure Truncate off to stop the O.S. automatically
truncating filenames when saving and therefore (possibly) overwriting an
old version of a file which I wanted to keep! A
5.11
5.11
Colton
5.11
From 5.10 page 20
5.11
5.11